﻿using UnityEngine;
using System.Collections;

namespace UI
{
    public class UIYggdrasilAnimation : MonoBehaviour
    {
        public TweenPosition position;
        public GameObject content;
        public TweenAlpha[] items; //五个碗
        public TweenPosition[] authors;//Icon
        public TweenAlpha[] arrows; 
        public TweenAlpha[] lightArrows;
        public GameObject[] frames;
        /// <summary>
        /// 进入过程
        /// </summary>
        public void In()
        {
            foreach(var item in items)
            {
                item.enabled = true;
                item.ResetToBeginning();
                item.PlayForward();
            }

            foreach(var author in authors)
            {
                author.enabled = true;
                author.ResetToBeginning();
                author.PlayForward();
            }

            foreach(var arrow in arrows)
            {
                arrow.enabled = true;
                arrow.ResetToBeginning();
                arrow.PlayForward();
            }

            foreach(var light in lightArrows)
            {
                light.enabled = true;
                light.ResetToBeginning();
                light.PlayForward();
            }
            
            foreach(var frame in frames)
            {
                frame.transform.localPosition = new Vector3(1, 90, 0);
            }
        }

        //全部出去的过程
        void Out()
        {
            position.enabled = true;
            position.ResetToBeginning();
            position.PlayForward();
            position.onFinished = new System.Collections.Generic.List<EventDelegate>();
            position.onFinished.Add(new EventDelegate(()=> 
            {
                content.transform.localPosition = Vector3.zero;
                In();
            }));
        }

        /// <summary>
        /// 点亮
        /// </summary>
        /// <param name="i"></param>
        public void Light(int i)
        {

        }

        public void SwitchGroup()
        {
            Out();
        }
    }
}